<!DOCTYPE html>
{__CONTENT__}

<link rel="stylesheet" type="text/css" href="__PLUGIN__/layui/css/layui.css">
<script type="text/javascript" src="__PLUGIN__/layer/layer.js"></script>



<script>

    // function go_url(to_url,from_url) {
    //     localStorage.setItem('url',from_url);
    //     window.location.href = to_url;
    // }
    // function back_url() {
    //     var from_url =localStorage.getItem('url');
    //
    //     window.location.href = from_url;
    // }

    function back_button() {
        // var url = window.location.pathname+window.location.search;
        var url = window.location.pathname;//https://www.cnblogs.com/hongmaju/p/5510988.html
        window.location.href = localStorage.getItem(url);
    }

    function go_button(to_url) {
        var from_url = window.location.href;
        var to_url2 = '';
        if (to_url.indexOf("?") >= 0) {
            to_url2 = to_url.split('?')[0];
        } else {
            to_url2 = to_url;
        }
        localStorage.setItem(to_url2, from_url);//当夜页面url
        window.location.href = to_url;
    }

    function go_view(id) {
        var from_url = window.location.href;
        var to_url = "{:url('view')}?id=" + id;
        if (to_url.indexOf("?") >= 0) {
            to_url2 = to_url.split('?')[0];
        } else {
            to_url2 = to_url;
        }
        localStorage.setItem(to_url2, from_url);//当夜页面url
        window.location.href = to_url;
    }

    function go_index() {
        window.location.href = '/';
    }

    function strLength(str,len) {
        var len = len*2;//要不截取少一半
        var strlen = 0;
        var s = "";
        for (var i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) > 128) {
                strlen += 2;
            } else {
                strlen++;
            }
            s += str.charAt(i);
            if (strlen >= len) {
                return s+"...";
            }
        }
        return s;
    }

    //时间格式截取 非时间戳
    function date(formatStr, fdate){
        var fTime, fStr = 'YmdHis';
        if (!formatStr)
            formatStr= "Y-m-d H:i:s";
        if (fdate)
            fTime = new Date(fdate);
        else
            fTime = new Date();
        var formatArr = [
            fTime.getFullYear().toString(),
            (fTime.getMonth()+1).toString(),
            fTime.getDate().toString(),
            fTime.getHours().toString(),
            fTime.getMinutes().toString(),
            fTime.getSeconds().toString()
        ];
        for (var i=0; i<formatArr.length; i++){
            formatStr = formatStr.replace(fStr.charAt(i), formatArr[i]);
        }
        return formatStr;
    }

    function check_login(url) {
        var u = window.location.href;

        $.ajax({
            type: "POST", //用POST方式传输
            dataType: "json", //数据格式:JSON
            url: "{:url('Member/check_login')}", //目标地址
            async: false,
            success: function (data) {


                if(data.code == 200){
                    window.location.href = url;
                    // layer.msg(data.mbessage);

                    return false;
                }else if(data.code == 201){

                    window.location.href = "{:url('Index/index')}"; //绑定房屋
                }else{
                    layer.msg(data.message);
                    setTimeout(function () {
                        window.location.href = "{:url('Member/login')}";
                    },1000);
                    return false;
                }
            }
        });
        if(url.indexOf("?") >= 0 ) {
            url = url.split('?')[0];
        }
        localStorage.setItem(url,u);//当夜页面url

    }


</script>
<style>

</style>


